import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:fluttertoast/fluttertoast.dart';

class HomeMineWidget extends StatelessWidget {
  HomeMineWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsetsDirectional.only(start: 17, top: 60, end: 17),
      child: Column(
        children: [
          _getTopContent(context),
          Container(
            margin: EdgeInsetsDirectional.only(top: 50),
            child: Column(
              children: [
                _getItemContent(0),
                _getItemContent(1),
                _getItemContent(2),
                _getItemContent(3),
                _getItemContent(4),
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget _getTopContent(BuildContext context) {
    return GestureDetector(child: Container(
      height: 80,
      child: Row(
        children: [
          Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text("登陆/注册",
                          style: TextStyle(
                              color: Colors.black,
                              fontSize: 30,
                              fontWeight: FontWeight.bold)),
                      Container(
                        margin: EdgeInsetsDirectional.only(start: 10),
                        child: Image.asset("images/home/ic_enter.png",
                            width: 16, height: 16, fit: BoxFit.cover),
                      )
                    ],
                  ),
                  Text(
                    "未绑定手机",
                    style: TextStyle(
                      color: Colors.black,
                      fontSize: 15,
                    ),
                  )
                ],
              )),
          Image.asset("images/home/ic_head.png",
              width: 80, height: 80, fit: BoxFit.cover)
        ],
      ),
    ),
    onTap: (){
      // Fluttertoast.showToast(msg: "1231",gravity: ToastGravity.CENTER,backgroundColor: Color.fromARGB(255, 25, 37, 37));
      Navigator.pushNamed(context, '/account');
    },);
  }

  final List<String> itemImg = [
    'images/home/ic_mine_item_1.png',
    'images/home/ic_mine_item_2.png',
    "images/home/ic_mine_item_3.png",
    "images/home/ic_mine_item_4.png",
    "images/home/ic_mine_item_5.png",
  ];
  final List<String> itemName = ["意见反馈", "黑名单", "用户协议", "隐私协议", "关于我们"];

  Widget _getItemContent(int index) {
    return Container(
      padding: const EdgeInsetsDirectional.only(top: 20, bottom: 20),
      child: Row(
        children: [
          Image.asset(itemImg[index], width: 30, height: 30, fit: BoxFit.cover),
          Padding(
              child:
                  Text(itemName[index], style: TextStyle(color: Colors.black)),
              padding: EdgeInsetsDirectional.only(start: 10)),
          Expanded(
              child: Container(
            alignment: AlignmentDirectional.centerEnd,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Offstage(
                  offstage: index != 4,
                  child: Text("版本号v1.1.2",
                      style: TextStyle(color: Colors.grey, fontSize: 12)),
                ),
                Image.asset("images/home/ic_right_enter.png",
                    width: 30, height: 30),
              ],
            ),
          ))
        ],
      ),
    );
  }
}
